﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Top.Api;
using Top.Api.Request;
using Top.Api.Response;


namespace tracentsure
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string appkey = "1032708884";
            string secret = "sandbox1512b3b4bd3a84c4792eba349";
            string url = "http://gw.api.tbsandbox.com/router/rest";
            ITopClient client = new DefaultTopClient(url, appkey, secret,"json");
            
            AlibabaAlihealthDrugKytUploadcircubillRequest req = new AlibabaAlihealthDrugKytUploadcircubillRequest();            
            req.BillCode = "bc001";
            req.BillTime = DateTime.Parse("2021-05-05 16:57:15");
            req.BillType = 201L;
            req.PhysicType = 3L;
            req.RefUserId = "320000000000127971";
            req.AgentRefUserId = "320000000000127971";
            req.FromUserId = "00000000000020671792";
            req.ToUserId = "d5f5f05c6af04e52ba7894d9bbf8e757";
            req.DestUserId = "d5f5f05c6af04e52ba7894d9bbf8e757";
            req.OperIcCode = "212000345";
            req.OperIcName = "张三";
            req.FileContent = "添写单据文件xml的加密串，加密过程看文档。XmlUtil类的createFileZipContent方法生成";
            req.UploadFileName = "单据文件00001.xml";
            req.ClientType = "2";
            req.QuReceivable = 10L;
            req.XtIsCheck = "0";
            req.XtCheckCode = "未验证通过原因";
            req.XtCheckCodeDesc = "未通过原因描述";
            req.DrugListJson = "[{\"codeCount\":100,\"commDrugId\":\"testCommDrugId0\",\"exprieDate\":1571131734945,\"physicInfo\":\"test0\",\"pkgSpec\":\"test0\",\"prepnCount\":10,\"produceBatchNo\":\"test0\",\"produceDate\":1571131734945},{\"codeCount\":100,\"commDrugId\":\"testCommDrugId1\",\"exprieDate\":1571131734945,\"physicInfo\":\"test1\",\"pkgSpec\":\"test1\",\"prepnCount\":10,\"produceBatchNo\":\"test1\",\"produceDate\":1571131734945}]";
            req.AssRefEntId = "5069452c34b94a778abaa26c2b40b305";
            req.DisEntId = "5069452c34b94a778abaa26c2b40b305";
            req.DisRefEntId = "5069452c34b94a778abaa26c2b40b305";
            req.ToPerson = "李某";
            req.FromPerson = "张某";
            req.OrderCode = "123456";
            req.FromBillCode = "123456";
            req.ToAddress = "收货地址XXX";
            req.FromAddress = "发货地址XXX";
            req.AssEntId = "5069452c34b94a778abaa26c2b40b305";
            AlibabaAlihealthDrugKytUploadcircubillResponse rsp = client.Execute(req);
            //Console.WriteLine(rsp.Body);
            textBox1.Text = rsp.Body;
        }
    }
}
